home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 520 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.2 KB

  1. Path: newsfeed.direct.ca!usenet
  2. From: mkla@direct.ca (Mike Klajnert)
  3. Newsgroups: comp.lang.c
  4. Subject: Question for "C" programmers.
  5. Date: Sat, 06 Jan 1996 14:42:26 GMT
  6. Organization: Internet Direct
  7. Message-ID: <4cm8mt$hlc@grid.direct.ca>
  8. NNTP-Posting-Host: 204.174.249.121
  9. X-Newsreader: Forte Free Agent 1.0.82
  10.  
  11.  
  12. Hi
  13.  
  14. This is my question for all "C" programmers who
  15. knows how to talk to news server.
  16.  
  17. My problem is that I can send only one command to news server,
  18. then I'll receive a respons.  To the next command server is 
  19. not responding.
  20.  
  21. here is part of code
  22.  
  23.  
  24.     iRet =  send( hSocket, (LPSTR)command, strlen( command)+1,
  25. NO_FLAGS); 
  26.     
  27.     if ( iRet == SOCKET_ERROR &&
  28.          WSAGetLastError() != WSAEWOULDBLOCK) {
  29.        MessageBox( NULL, "The send() function returned a socket
  30. error.",
  31.                    PROG_NAME, MB_OK|MB_ICONSTOP);
  32.        iLastError = WSAGetLastError();
  33.     }
  34.     else {
  35.        iLength = recv( hSocket, (LPSTR)sReceiveBuffer,
  36.                       sizeof( sReceiveBuffer), NO_FLAGS);
  37.            
  38.  
  39.        if ( iLength == 0 || iLength == SOCKET_ERROR ) {
  40.            MessageBox(NULL, "The recv() function returned a socket
  41. error.",
  42.                       PROG_NAME, MB_OK|MB_ICONSTOP);
  43.        }
  44.        sReceiveBuffer[iLength] = '\0';
  45.            
  46.        sscanf( sReceiveBuffer, "%hd %hd %hd %hd %s", 
  47.                &GroupInfo.error, &GroupInfo.numberofarticles,
  48.                &GroupInfo.fromarticlenumber,
  49. &GroupInfo.toarticlenumber,
  50.                GroupInfo.groupname);
  51.     }   
  52.     
  53.  
  54.     sprintf( command, "HEAD %hd\015\012",
  55. GroupInfo.fromarticlenumber);
  56.  
  57.     iLength = strlen( command);             
  58.                     
  59.     iRet =  send( hSocket, (LPSTR)command, iLength+1, NO_FLAGS); 
  60.  
  61.     if ( iRet == SOCKET_ERROR &&
  62.        WSAGetLastError() != WSAEWOULDBLOCK) {
  63.        MessageBox(NULL, "The send() function returned a socket
  64. error.",
  65.                   PROG_NAME, MB_OK|MB_ICONSTOP);
  66.        iLastError = WSAGetLastError();
  67.     }
  68.     else {   
  69.         
  70.         iLength = recv( hSocket, (LPSTR)sReceiveBuffer,
  71.                         1024, NO_FLAGS);
  72.                         
  73. at this point recv waits forever
  74.  
  75. it doesen't meatter if it is HEAD or QUIT after second send
  76. I don't get any response from server.
  77.  
  78. any ideas?
  79.  
  80. all help appreciated.
  81.  
  82. mkla@direct.ca
  83.  
  84.  
  85.  
  86.